package daoFactory;

import dao.IUserDao;
import util.ReadConfig;

import java.util.Map;

public class UserDaoFactory implements IFactory {
//    private static UserDaoFactory fac=new UserDaoFactory();
//    private UserDaoFactory(){}
//    public static UserDaoFactory getInstance(){
//        return fac;
//    }

    //    private static UserDaoFactory fac=null;
//    private UserDaoFactory(){}
//    public static UserDaoFactory getInstance(){
//        if(fac==null){
//            fac=new UserDaoFactory();
//
//        }
//        return fac;
//    }
    private static class SingleFactory {
        private static final UserDaoFactory fac = new UserDaoFactory();
    }
    private UserDaoFactory() {
    }
    public static final UserDaoFactory getInstance() {
        return UserDaoFactory.SingleFactory;
    }
//    public static UserDaoFactory getInstance() {
//        @Override
//        public IUserDao createDao (String type) throws Exception {
//            Map<String, String> map = ReadConfig.read();
//            String classname = map.get(type);
//            IUserDao dao = (IUserDao) Class.forName(classname).newInstance();
//
//            return dao;
//        }
//    }

    public static void main(String[] args) {
        UserDaoFactory.getInstance();
    }
